package com.beerbear.consumer.config.listener;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

/**
 * @Author: Beer Bear
 * @Description: 监听工作队列
 * @Date: 2021/9/3 8:22
 */
@Component
public class SpringRabbitMQListenerForWorkQueue {

    @RabbitListener(queues = "work queue")
    public void listenWorkQueue1(String msg) throws InterruptedException {
        System.out.println("消费者1接收消息:" + msg + LocalTime.now());
        Thread.sleep(20);
    }

    @RabbitListener(queues = "work queue")
    public void listenWorkQueue2(String msg) throws InterruptedException {
        System.out.println("消费者2接收消息:" + msg + LocalTime.now());
        Thread.sleep(200);
    }
}
